package com.yoomiito.app.ui.my.remain.deduct

import android.text.TextUtils
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yoomiito.app.R
import com.yoomiito.app.model.my.DeductMoneyDetail
import com.yoomiito.app.model.my.MyMoneyDetailInfo
import com.yoomiito.app.utils.DensityUtil
import com.yoomiito.app.utils.ImageLoader
import com.yoomiito.app.utils.ResUtil
import com.yoomiito.app.utils.SpannableUtils

class DeductMoneyDetailAdapter(data: List<DeductMoneyDetail>?) : BaseQuickAdapter<DeductMoneyDetail, BaseViewHolder>(R.layout.item_my_money_detail, data) {

    override fun convert(helper: BaseViewHolder, item: DeductMoneyDetail?) {
        helper.setText(R.id.tv_time, item?.ctime)
        helper.setText(R.id.tv_content, item?.accountTypeDes)
        val iv = helper.getView<ImageView>(R.id.agent_flag)
        iv.visibility = if(item?.biz_type==4) View.VISIBLE else View.GONE
        if (iv.visibility == View.VISIBLE){
            val lp = iv.layoutParams as LinearLayout.LayoutParams
            lp.width=DensityUtil.dp2px(32f)
            lp.height = DensityUtil.dp2px(18f)
        }
        iv.setImageResource(R.drawable.icon_svip_apply)
//        when {
//            TextUtils.isEmpty(item?.) ->
//            else -> {
//                iv.visibility = View.VISIBLE
//                ImageLoader.getInstance().into(iv.context, item.image_url, iv)
//            }
//        }

        helper.setText(R.id.tv_subtitle, item?.accountTypeDesDetail)
        val moneyTv = helper.getView<TextView>(R.id.tv_money)
        moneyTv.setTextColor(
                ResUtil.getColor(if (item?.money?.contains("-")!!) R.color.color_balk_333333 else R.color.color_4AC142)
        )
        moneyTv.text = SpannableUtils.handlePrice(item?.money)
    }
}
